test(razorpaybilling): drive coverage 8.5% -> 100%#140
Merged
Conversation
Every Portal method (SubscriptionID, CancelAtCycleEnd, CancelImmediately, ListSubscriptionInvoices, PaymentUpdateURL, ChangePlan, FetchSubscriptionDetails) plus the toInt64 / pickInvoiceTimestamp helpers now exercise their happy path, every error branch (4xx/5xx upstream, no-config, DB error, sql.ErrNoRows, malformed/missing fields), and every callWithBreaker arm — including the open-state rejection and the WithOnOpen callback on the singleton breaker. The Razorpay REST surface is mocked via httptest.Server; no live API calls. A one-line test seam in portal.go (newClientForPortal) lets tests retarget the SDK's BaseURL at the mock; production callers go through the original NewTimeoutClient unchanged. Coverage: 8.5% -> 100.0% of statements (go test -cover). Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
internal/razorpaybilling/portal_coverage_test.gocovering every Portal method, both pure helpers (toInt64,pickInvoiceTimestamp), and everycallWithBreakerbranch including the singleton's open-state rejection andWithOnOpencallback.portal.go:newClientForPortal(defaults toNewTimeoutClient) lets tests retarget the SDK'sBaseURLat anhttptest.Server. Production callers go through the original constructor unchanged.SubscriptionIDandChangePlanpersistence).Coverage
go tool cover -func).Test plan
go test ./internal/razorpaybilling -coverprofile=cov.out -count=1-> 100.0%go test ./internal/razorpaybilling -race -count=1-> passgo vet ./internal/razorpaybilling/...-> cleango build ./internal/razorpaybilling/...-> cleanNotes:
t.Cleanup(resetBreaker)so ordering across the rest of the file is irrelevant.Co-Authored-By: Claude Opus 4.7 (1M context) noreply@anthropic.com
Generated with Claude Code